# -*- coding: utf-8 -*-
# @Time: 2025/9/21 3:16
# @Author: foxhuty
# @File: cocurrency.py

import asyncio
from timer import async_timer


async def greet(name:str,delay:int):
    await asyncio.sleep(delay)
    return f'Hello, {name}!'


# @async_timer
# async def main():
#     result1=await greet('tommy',1)
#     print(result1)
#     result2=await greet('tony',2)
#     print(result2)
# 并发运行
@async_timer
async def main():
    task1=asyncio.create_task(greet('tommy',2))
    task2=asyncio.create_task(greet('tony',1))
    result1=await task1
    print(result1)
    result2=await task2
    print(result2)





if __name__ == '__main__':
    asyncio.run(main())
    print(dir(asyncio.wait))
